<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		
		if(!$this->session->userdata("user_id"))
		{
			$this->load->model('show_content');
			 $data['chuyenmuc']=$this->show_content->select_chuyenmuc();
			  $MaCM=substr($data['chuyenmuc'],0,-1);
	        $MaCM=explode('-',$MaCM);
	        $list_chuyenmuc=array();
	        foreach ($MaCM as $key ) {
	            $list_chuyenmuc[]=$key;
	            
	        }

		  	
		      
	         $data1['query1'] = $this->show_content->big_menu();
	         $data1['query2'] = $this->show_content->small_menu();
	         $data['slider']=$this->show_content->slider();
	         $this->load->view('view_head.php');
			$this->load->view('view_header.php',$data1);
			$this->load->view('view_slide.php',$data);  
			
			$this->load->view('module_view_noidung_tren.php');
			 foreach ($list_chuyenmuc as $key ) {
	        	# code...
	        	$data['query']= $this->show_content->select_top1baiviet($key);
	        	  $data['top3khactop1']= $this->show_content->select_top3baivietkhactop1($key);
	        	$this->load->view('module_view_noidung.php',$data);

	        }
	       	$data['modules']=$this->show_content->show_modules();
			$this->load->view('view_body.php',$data);
			
			$this->load->view('view_footer.php');
			// $this->login();
		}
		else
		{
			$this->load->model('show_content');
			 $data['chuyenmuc']=$this->show_content->select_chuyenmuc();
			  $MaCM=substr($data['chuyenmuc'],0,-1);
	        $MaCM=explode('-',$MaCM);
	        $list_chuyenmuc=array();
	        foreach ($MaCM as $key ) {
	            $list_chuyenmuc[]=$key;
	            
	        }

		  	
		      
	         $data1['query1'] = $this->show_content->big_menu();
	         $data1['query2'] = $this->show_content->small_menu();
	         $data['slider']=$this->show_content->slider();
	         $this->load->view('view_head.php');
	         
			$this->load->view('view_header.php',$data1);
			$this->load->view('view_slide.php',$data);  
			
			$this->load->view('module_view_noidung_tren.php');
			 foreach ($list_chuyenmuc as $key ) {
	        	# code...
	        	$data['query']= $this->show_content->select_top1baiviet($key);
	        	  $data['top3khactop1']= $this->show_content->select_top3baivietkhactop1($key);
	        	$this->load->view('module_view_noidung.php',$data);

	        }
	       	$data['modules']=$this->show_content->show_modules();
			$this->load->view('view_body.php',$data);
			
			$this->load->view('view_footer.php');
			$this->load->view('link_admin.php');
		}

	
	}
	function content($UrlBV)
	{
		$this->load->model('show_content');
		 $data1['query1'] = $this->show_content->big_menu();
         $data1['query2'] = $this->show_content->small_menu();
         $data['noidungbaiviet']=$this->show_content->show_noidungbaiviet($UrlBV);
         $data['baivietlienquan']=$this->show_content->baivietcungchuyenmuc();
         $data['slider']=$this->show_content->slider();
           $this->load->view('view_head.php');
		$this->load->view('view_header.php',$data1);
		$this->load->view('view_slide.php',$data);
		//$this->load->view('view_canhtrai.php');
		 $this->load->view('view_noidung_baiviet.php',$data);
		$this->load->view('view_footer.php');

	}
	// function login()
	// {
	// 	$this->load->model('show_content');
	// 	$userN=$this->input->post('username');
	// 	$passW=$this->input->post('password');

	// 	$result=$this->show_content->modellogin($userN,$passW);
		
	// 	if($result)
	// 	{

			
	// 		return true;

	// 	}
		
		
	// }
		
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */